// 1.模板方法模式定义
class Person {
    dinner() {
        this.buy();
        this.cooke();
        this.eat();
    };
    buy() {
        throw new Error('必须在子类中实现buy方法');
    };
    cooke() {
        throw new Error('必须在子类中实现cooke方法');
    };
    eat() {
        throw new Error('必须在子类中实现eat方法');
    }
}

class ChildPerson extends Person {
    buy() {
        console.log('买土豆');
    };
    cooke() {
        console.log('做土豆');
    };
    eat() {
        console.log('吃土豆');
    }
}

let personInstance = new ChildPerson();
personInstance.dinner();